
from fastapi import APIRouter

from app.business.sfc_chat_service import (
    chat_history, 
    rag_chatDetailBiz_stream, 
    rag_chatDetailMdl,
    one_chat,
    search_topk,
    search
)

sfc_stream_router = APIRouter()
_active = True  # 激活状态



@sfc_stream_router.get("/sfc/chat_history")
def chat_history_x():
    chat_msg = chat_history()
    return chat_msg


@sfc_stream_router.get("/sfc/search")
def search_x(collection_name: str, filter_str: str):
    search_result = search(collection_name=collection_name, filter_prompt_result=filter_str)
    return search_result

@sfc_stream_router.get("/sfc/onechat")
def one_chat_x(query: str):
    result = one_chat(query=query)
    return result

@sfc_stream_router.get("/sfc/words_replace")
def words_replace_x(query: str):
    words = {
        "Tribunal": "Court",
        "tribunal": "court",
    }
    for k, v in words.items():
        query = query.replace(k, v)
    return query

@sfc_stream_router.get("/sfc/search_topk")
def search_topk_x(collection_name: str, query: str, top_k:int):
    result = search_topk(collection_name, query, top_k)
    return result


            



